//
//  THClippingCircle.m
//  duolaCard
//
//  Created by 希达 on 2018/5/8.
//  Copyright © 2018年 zyy. All rights reserved.
//

#import "THClippingCircle.h"

@implementation THClippingCircle
- (void)dealloc {
    NSLog(@"%@释放了", NSStringFromClass(self.class));
}

- (void)drawRect:(CGRect)rect
{

    CGFloat width = self.bounds.size.width;
    CGFloat height = self.bounds.size.height;
    //1.获取上下文
    CGContextRef contextRef = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(contextRef, 3);//线条的粗细
    //2.描述路径
    UIBezierPath * path = [UIBezierPath bezierPath];
    switch (self.tag) {
        case 0: {
            [path moveToPoint:CGPointMake(width/2 - 3, height / 2 + 15)];
            [path addLineToPoint:CGPointMake(width / 2 - 3, height / 2 - 3)];
            [path addLineToPoint:CGPointMake(width/2 + 15, height / 2 - 3)];
        } break;
        case 1: {
            [path moveToPoint:CGPointMake(width/2 - 3, height / 2 - 15)];
            [path addLineToPoint:CGPointMake(width / 2 - 3, height / 2 + 3)];
            [path addLineToPoint:CGPointMake(width/2 + 15, height / 2 + 3)];
        } break;
        case 2: {
            [path moveToPoint:CGPointMake(width/2 - 15, height / 2 - 3)];
            [path addLineToPoint:CGPointMake(width / 2 + 3, height / 2 - 3)];
            [path addLineToPoint:CGPointMake(width/2 + 3, height / 2 + 15)];
        } break;
        case 3: {
            [path moveToPoint:CGPointMake(width/2 + 3, height / 2 - 15)];
            [path addLineToPoint:CGPointMake(width / 2 + 3, height / 2 + 3)];
            [path addLineToPoint:CGPointMake(width/2 - 15, height / 2 + 3)];
        } break;
        default:  break;
    }

    //设置颜色
    [[UIColor blackColor] setStroke];
    //3.添加路径
    CGContextAddPath(contextRef, path.CGPath);
    //显示路径
    CGContextStrokePath(contextRef);
}



@end
